package com.example.musicplayer.gobang;

public class GobangAI {
    public static final int GRADE_1 = 1;
    public static final int GRADE_2 = 2;
    public static final int GRADE_3 = 3;
    //set the ai grade
    private int mGrade;
    private final AI_1 mAI_1;
    private final AI_2 mAI_2;
    private final AI_3 mAI_3;
    private final AI_4 mAI_4;
    private final Gobang mGobang;

    public GobangAI(Gobang gobang) {
        this(gobang, GRADE_1);
    }

    public GobangAI(Gobang gobang, int grade) {
        setGrade(grade);
        mGobang = gobang;
        mAI_1 = new AI_1(mGobang);
        mAI_2 = new AI_2(mGobang);
        mAI_3 = new AI_3(mGobang);
        mAI_4 = new AI_4(mGobang);
    }

    public void setGrade(int grade) {
        mGrade = grade;
    }

    public Location nextLocation() {
        if (mGobang.getCounts() == 0) {
            return new Location(mGobang.getChessBoardSize() / 2, mGobang.getChessBoardSize() / 2);
        }
        switch (mGrade) {
            case GRADE_2:
                return mAI_2.nextLocation();
            case GRADE_3:
                return mAI_4.nextLocation();
            case GRADE_1:
            default:
                return mAI_1.nextLocation();
        }
    }
}